home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / client / include / chunk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  6.7 KB  |  204 lines

  1. #ifndef __CHUNK_H__
  2. #define __CHUNK_H__
  3. /*
  4.  *   $RCSfile: chunk.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:19 $      
  7.  */ 
  8. /**********************************************************************
  9. * EXODUS Database Toolkit Software
  10. * Copyright (c) 1991 Computer Sciences Department, University of
  11. *                    Wisconsin -- Madison
  12. * All Rights Reserved.
  13. *
  14. * Permission to use, copy, modify and distribute this software and its
  15. * documentation is hereby granted, provided that both the copyright
  16. * notice and this permission notice appear in all copies of the
  17. * software, derivative works or modified versions, and any portions
  18. * thereof, and that both notices appear in supporting documentation.
  19. *
  20. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  21. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  22. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  23. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  24. *
  25. * The EXODUS Project Group requests users of this software to return 
  26. * any improvements or extensions that they make to:
  27. *
  28. *   EXODUS Project Group 
  29. *     c/o David J. DeWitt and Michael J. Carey
  30. *   Computer Sciences Department
  31. *   University of Wisconsin -- Madison
  32. *   Madison, WI 53706
  33. *
  34. *     or exodus@cs.wisc.edu
  35. *
  36. * In addition, the EXODUS Project Group requests that users grant the 
  37. * Computer Sciences Department rights to redistribute these changes.
  38. **********************************************************************/
  39.  
  40.  
  41. typedef struct ChunkPage CHUNKPAGE;
  42.  
  43. /*
  44.  * Definition of a chunk descriptor.
  45.  * Each chunk descriptor has three parts:
  46.  *    1) the descriptor proper, which contains general information 
  47.  *       about the chunk.
  48.  *    2) a list of chunk user descriptors, where each user descriptor 
  49.  *       contains information about the user that is accessing the chunk.
  50.  *    3) a page descriptor, which contains information about the pages in
  51.  *       the chunk.
  52.  *
  53.  * We begin by defining what the chunk user descriptors look like.
  54.  * There will be one chunk descriptor for each user accessing the chunk.  
  55.  *
  56.  * When describing pages in a versioned large object, the term "shared"
  57.  * will often be used.  A shared page is one in which for some pointer 
  58.  * on the path to the page from the root node of the object the
  59.  * share flag is set.
  60.  */
  61.  
  62. typedef struct {
  63.  
  64.     TWO                type;            /* indicates this is type chunk            */
  65.     TWO                flags;            /* status flag for chunk                */
  66.     char            *basePtr;        /* base pointer for accessing chunk        */
  67.     int                byteCount;        /* bytes accessible to user                */
  68.     char            *bufFrame;        /* actual beginning of chunk            */
  69.     int                totalLength;    /* total bytes that are in the chunk    */
  70.     BUFGROUP        *bufGroup;        /* buffer group user is working in        */
  71.     TWO                firstPage;        /* page descriptor index of first page    */
  72.     TWO                pageCount;        /* page descriptors that are valid        */
  73.     TWO                descCount;        /* number of allocated page descriptors    */
  74.     TWO                dirtyPages;        /* number of dirty pages in the chunk    */
  75.     TWO                bufCount;        /* number of buffers in chunk            */
  76.     TWO                sharedPages;    /* indicates number of shared pages     */
  77.     SLOTINDEX        objectSlot;        /* the slot of the object being accessed*/
  78.     int                bufIndex;        /* index of the first buffer            */
  79.     PAGE2SIZE        buf2size;        /* number of buffers in chunk            */
  80.     int                firstOffset;    /* offset in first page of first user byte    */
  81.     LISTELEMENT        memberList;        /* hangs off the group/freelist struct    */
  82.     CHUNKPAGE        *chunkPage;        /* array of page descriptors            */
  83.     USERDESC        *userDesc;        /* a pointer to the user descriptor        */
  84.     BUFINFO            *bufInfo;
  85.     FID                fid;
  86.     PID                rootPid;
  87.     SLOTINDEX        rootSlot;        /* set to slot is root on slotted page*/
  88.  
  89. #if MAGIC_CHECKING IS_ENABLED
  90.  
  91.     MAGIC        magic;                    /* magic number for debugging                */
  92.  
  93. #endif
  94.  
  95.  
  96. } CHUNKDESC;
  97.  
  98. /*
  99.  *    Define chunk state flags
  100.  */
  101. #define CHUNK_INVALID    0x0                /* Chunk is not valid                */
  102. #define CHUNK_VALID        0x1                /* Chunk contains valid data        */    
  103. #define CHUNK_USED        0x2                /* CHUNK_VALID & in a buffer group    */
  104. #define CHUNK_FIXED        0x4                /* CHUNK_VALID & CHUNK_USED and        */
  105.                                         /* fixed in a buffer group            */
  106. #define CHUNK_DIRTY        0x8                /* CHUNK_VALID and a page is dirty    */
  107.  
  108.  
  109. #define CHUNK_IS_DIRTY(_chunkDesc)        \
  110.     ((_chunkDesc)->flags & CHUNK_DIRTY)
  111.  
  112. #define DIRTY_CHUNK(_chunkDesc)            \
  113.     (_chunkDesc)->flags |= CHUNK_DIRTY
  114.  
  115. #define CLEAN_CHUNK(_chunkDesc)            \
  116.     (_chunkDesc)->flags &= (~CHUNK_DIRTY)
  117.  
  118. #define CHUNK_IS_USED(_chunkDesc)        \
  119.     ((_chunkDesc)->flags & CHUNK_USED)
  120.  
  121. #define CHUNK_IS_FREE(_chunkDesc)        \
  122.     (!((_chunkDesc)->flags & CHUNK_USED))
  123.  
  124. #define CHUNK_IS_VALID(_chunkDesc)        \
  125.     ((_chunkDesc)->flags & CHUNK_VALID)
  126.  
  127. /*
  128.  *    define the magic number for chunk descriptors
  129.  */
  130. #define CHUNKDESC_MAGIC    0x6d2b90c1
  131.  
  132.  
  133. /*
  134.  *    The page information structure that
  135.  *    keeps track of pages with chunks
  136.  */
  137. struct ChunkPage {
  138.  
  139.     TWO                flags;
  140.     SLOTINDEX        slot;
  141.     int                size;
  142.     int                offset;
  143.     PID                pid;
  144.     BOOL            shared;            /* marks page shared by another verison */
  145.     PAGEHASH        *pageHash;
  146.     CHUNKDESC        *chunkDesc;
  147.     GROUPLINK        *nodeLink;
  148.     LISTELEMENT        hashList;
  149.     SHORTPID        parentPid;
  150.     SLOTINDEX        parentSlot;
  151. };
  152.  
  153. #define PAGE_INVALID    0x0
  154. #define PAGE_VALID        0x1
  155. #define PAGE_DIRTY        0x2
  156.  
  157.  
  158. /*
  159.  * Definition for the BufTable.
  160.  * The BufTable is an array that describes how each buffer frame is being used.
  161.  * If a frame is marked as valid and contains chunk data, then the 
  162.  * chunkDesc field will be non-NULL and will point to the chunk's descriptor.
  163.  * If a frame is marked as valid and contains a slotted page, then the 
  164.  * hashPtr field will be non-NULL and will point to the page's hash entry.
  165.  *
  166.  * When a frame is in the pool of free frames (i.e., it is part of the
  167.  * free list), the the frame is tagged as free, and the fields size, 
  168.  * nextBuf, prevBuf, and firstInBlk are set accordingly to link the 
  169.  * frame into the free list.
  170.  *
  171.  * Note that in a free block, the fields free and firstInBlk are set for
  172.  * each buffer of the free block, whereas, the fields size, freeBlk, 
  173.  * and numClean are set in just the first buffer of the free block.
  174.  */
  175. typedef struct BufInfo {       
  176.  
  177.     ONE            type;
  178.     TWO            index;
  179.     char        *blockInfo;    
  180.  
  181. }; 
  182.  
  183.  
  184. /*
  185.  * Definitions for IO dependencies.
  186.  * There are two types of IO dependencies.
  187.  *    - page dependencies of the form slotted page depends on slotted page.
  188.  *    - chunk dependencies of the form slotted page depends on chunk.
  189.  *
  190.  * If the dependency is a page dependency, then the pid field
  191.  * will be non-NULL and will contain the page's pid.
  192.  * If the dependency is a chunk dependency, then the chunkDesc field
  193.  * will be non-NULL and will point to the chunk's descriptor.
  194.  */
  195. typedef struct dependency {
  196.  
  197.     PID         pid;                    /* page dependency */
  198.     CHUNKDESC  *chunkDesc;                /* chunk dependency */
  199.     struct      dependency *nextDep;     /* the next dependency */
  200.  
  201. } DEPENDENCY;
  202.  
  203. #endif __CHUNK_H__
  204.